package com.leadingsoft.pwxk.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.leadingsoft.pwxk.converter.DrainInfoConverter;
import com.leadingsoft.pwxk.dto.DrainInfoDto;
import com.leadingsoft.pwxk.model.DrainInfo;
import com.leadingsoft.pwxk.repository.DrainInfoRepository;
import com.leadingsoft.pwxk.service.DrainInfoService;

@Service
public class DrainInfoServiceImpl implements DrainInfoService {

	@Autowired
	private DrainInfoRepository drainInfoRepository;
	@Autowired
	private DrainInfoConverter drainInfoConverster;

	@Override
	public DrainInfoDto get(String dataid) {
		List<DrainInfo> findByDataid = drainInfoRepository.findByDataid(dataid);
		return drainInfoConverster.toDto(findByDataid == null ? null : findByDataid.get(0));
	}

	@Override
	public List<DrainInfoDto> findByDataId(String dataid) {
		return drainInfoConverster.toDto(drainInfoRepository.findByDataid(dataid));
	}

}
